package com.davetrudes.jung.client.visualization.event;

import com.google.gwt.event.shared.GwtEvent;

public class ChangeEvent 
	extends GwtEvent<ChangeListener>
{
	/**
     * Event type for drag start events. Represents the meta-data associated with
     * this event.
     */
    public static final GwtEvent.Type<ChangeListener> TYPE = new GwtEvent.Type<ChangeListener>();
    
	protected Object source;
	
	public ChangeEvent(Object source){
		if (source == null){
			throw new IllegalArgumentException("Given source is null");
		}
		this.source = source;
	}
	
	public Object getSource(){
		return source;
	}
	
	public String toString(){
		return getClass().getName() + "[source: " + source + "]";
	}

	@Override
	public Type<ChangeListener> getAssociatedType() {
		return TYPE;
	}

	@Override
	protected void dispatch(ChangeListener handler) {
		handler.stateChanged(this);
		
	}
}
